package com.focusai.efairy.ui.adapter.project;

import android.view.View;

import com.focusai.efairy.R;
import com.focusai.efairy.model.response.ProjectManageResponse;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerAdapter;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerViewHolder;

/**
 * Created by luo_guangwen on 2017/9/18.
 */

public class ProjectSelectDevAdapter extends BaseRecyclerAdapter<ProjectManageResponse.DevItem> {


    @Override
    protected int getItemLayoutId() {
        return R.layout.item_dev_select;
    }

    @Override
    protected void onBindBaseRecyclerViewHolder(final BaseRecyclerViewHolder holder, final int position) {
        holder.setText(R.id.text_name, mList.get(position).efairydevice_name);
        holder.setText(R.id.text_dev_id, mList.get(position).efairydevice_id +"");
        if (mList.get(position).isSelected){
            holder.getImageView(R.id.iv_select).setImageResource(R.drawable.icon_selected);
        }else {
            holder.getImageView(R.id.iv_select).setImageResource(R.drawable.icon_no_select);
        }
        holder.getView(R.id.llayout_item).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mList.get(position).isSelected = !mList.get(position).isSelected;
                notifyDataSetChanged();
            }
        });
    }
}

